﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Newtonsoft.Json;
using System.IO;

namespace jsontest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            StringWriter sw = new StringWriter();
            JsonWriter writer = new JsonTextWriter(sw);
           
            int i = 0;
            
            writer.WriteStartObject();
            foreach(string line in richTextBox1.Lines)
            {
                 
                 writer.WritePropertyName(i.ToString());
                 writer.WriteValue(line);
            
           
                i++;
            }
            writer.WriteEndObject();
            writer.Flush();
            string jsonText = sw.GetStringBuilder().ToString();
            richTextBox2.AppendText(jsonText);
        }

       
    }
}
